import fetch from '@system.fetch';
import router from '@system.router';
export default {
    data: {
        title1: 'Create Account',
        data1:'第一页数据',
        userName:'',
        phoneNum:'',
        vcode:'',
        tipTextTap:false,
        tipText:''
    },
    to(){
        router.push({
            uri:"pages/text2Page/text2Page",
            params:{
                data2:this.data1
            }
        })
    },
    getCode(){
        fetch.fetch({
            url: 'http://120.78.198.170:3100/getVerificationCode',
            success: function(response) {
//JSON.stringify() 方法将一个 JavaScript 对象或值转换为 JSON 字符串，
                console.info("fetch success:@@:"+JSON.stringify(response.data));
//JSON.parse() 方法用来解析JSON字符串，构造由字符串描述的JavaScript值或对象。
                console.log("验证码："+JSON.parse(response.data).code)
//                that.responseData = JSON.stringify(response);
            },
            fail: function() {
                console.info("fetch fail");
            }
        });
    },
    userNameChange(){
      this.tipTextTap=false
    },
    phoneChange(){
        this.tipTextTap=false

    },
    codeChange(){
        this.tipTextTap=false

    },

    faSong(result){
        console.log("我点击了")
        console.log("表单值："+result.value.userName+'@@'+result.value.phoneNum+'@@'+result.value.vCode)
        this.userName=result.value.userName
        this.phoneNum=result.value.phoneNum
        this.vcode=result.value.vCode

        var that = this;


        if(result.value.vCode==''){
            this.tipTextTap = true
            this.tipText='验证码不能为空'

        }else if(result.value.userName==''){
            this.tipTextTap = true

            this.tipText='用户名不能为空'

        }else if (result.value.phoneNum=='') {
            this.tipTextTap = true

            this.tipText='手机号不能为空'

        }else{

            fetch.fetch({
                url: 'http://120.78.198.170:3100/registerTest?userName='+this.userName+'&phoneNum='+this.phoneNum+'&vCode='+this.vcode,
                success: function(response) {
                    console.info("fetch success"+JSON.stringify(response.data));
                    let aa = JSON.parse(response.data)
                    console.log("aa值为："+aa)
                    console.log("aa值为2："+aa.result)
                    console.log("aa值为："+JSON.stringify(aa))
                    console.log(aa.result=='success')
                    if(aa.result == 'success'){
                        console.log("执行成功函数")
                        router.push({uri:"pages/text2Page/text2Page",params:{userName:that.userName}})
                    }
                },
                fail: function() {
                    console.info("fetch fail");
                }
            });

        }



    }

}
